package com.yh.serviceimpl;

import com.yh.dao.PermissionDao;
import com.yh.javabean.Permission;
import com.yh.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Auther: als
 * @Date: 2024/5/27 - 05 - 27 - 10:28
 * @Description: com.yh.serviceimpl
 * @version: 1.0
 */
@Service("permissionService")
public class PermissionServiceImpl implements PermissionService {
    @Autowired   //(required = false) 不会识别容器
    PermissionDao permissionDao;

    @Override
    public List<Permission> findAll() {
        //调用mapper方法，
        return permissionDao.selectAll();
    }

    @Override
    public List<Permission> findByUid(int uid) {
        return permissionDao.selectByUid(uid);
    }

    @Override
    public List<Permission> findAll(String permissionName) {
        return permissionDao.selectpermissionName(permissionName);
    }

    @Override
    public void addPermission(Permission permission) {
        permissionDao.insertPermission(permission);
    }

    @Override
    public void delete(int id) {
        permissionDao.deleteById(id);
    }

    @Override
    public void editPermission(Permission permission) {
        permissionDao.updatePermission(permission);
    }

    @Override
    public Permission findById(int id) {
        return permissionDao.selectById(id);
    }

    //权限批量删除
    @Override
    public void deleteIds(List<Integer> ids) {
        permissionDao.deleteByList(ids);
    }
}
